﻿@model FollowPeers.Models.PublicationModel
@{
    ViewBag.Title = "Edit Publication";
}
@Html.Partial("_Header")
@Html.Partial("_SideBar2")
<div class="grid_10">
    <div class="box">
        <h2>
            Edit Publication</h2>
        @Script("jquery.validate.min.js")
        @Script("jquery.validate.unobtrusive.min.js")
        @Script("jquery.bgiframe.js")
        @Script("jquery.mcdropdown.js")
        @Script("modernizr-1.7.min.js")
        @Script("jquery-ui-1.8.11.js")
        @Script("jquery.tools.min.js")
        @Script("jquery.rte.js")
        <link rel="stylesheet" type="text/css" href="../../Content/css/jquery.mcdropdown.css" />
        <link href="../../Content/css/jquery-ui.css" rel="stylesheet" type="text/css" />
        @using (Html.BeginForm())
        {
            @Html.ValidationSummary(true)
            <fieldset>
                <legend>Edit Publication Details!</legend>
                @*-----------PublicationId-----------*@
                @Html.HiddenFor(model => model.publicationID)
                @*-----------OwnerID-----------*@
                @Html.HiddenFor(model => model.ownerID)
                @*-----------ViewCount-----------*@
                @Html.HiddenFor(model => model.viewCount)
                @*-----------Title-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.title, "Title ")
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.title, new { size = 78 })
                    @Html.ValidationMessageFor(model => model.title)
                </div>
                @*-----------Status-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.status, "Status ")
                </div>
                <div class="editor-field">
                    @{
            List<string> publicationstatus = new List<string>();
            publicationstatus.Add("In Preparation");
            publicationstatus.Add("In Review");
            publicationstatus.Add("In Press");
            publicationstatus.Add("Published");
            publicationstatus.Add("N.A.");
                    }
                    @Html.DropDownList("Status", new SelectList(publicationstatus))
                    @Html.ValidationMessageFor(model => model.status)
                </div>
                @*-----------Author-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.author, "Author(s) ")
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.author, new { size = 78 })
                    @Html.ValidationMessageFor(model => model.author)
                </div>
                @*-----------Type-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.type, "Type ")
                </div>
                <div class="editor-field">
                    @{
            List<string> publicationtype = new List<string>();
            publicationtype.Add("Book");
            publicationtype.Add("Conference");
            publicationtype.Add("Journal");
            publicationtype.Add("Thesis");
            publicationtype.Add("Other");
                    }
                    @Html.DropDownList("Type", new SelectList(publicationtype))
                    @Html.ValidationMessageFor(model => model.type)
                </div>
                @*-----------Journal-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.journal, "Journal")
                </div>
                <div class="editor-field">
                    <input id="journal" name="journal" type="text" value="@Model.journal" style="margin-left: 0px; width: 250px"/>
                </div>
                @*-----------Publisher-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.publisher, "Publisher")
                </div>
                <div class="editor-field">
                    <input id="publisher" name="publisher" type="text" value="@Model.publisher" style="margin-left: 0px; width: 250px" />
                </div>
                @*-----------Conference-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.conference, "Conference")
                </div>
                <div class="editor-field">
                    <input id="conference" name="conference" type="text" value="@Model.conference" style="margin-left: 0px; width: 250px" />
                </div>
                @*-----------University-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.university, "University ")
                </div>
                <div class="editor-field">
                    <input id="university" name="university" type="text" value="@Model.university" style="margin-left: 0px; width: 250px" />
                </div>
                @*-----------Year-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.year, "Year ")
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.year)
                    @Html.ValidationMessageFor(model => model.year)
                </div>
                @*-----------Issue-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.issue, "Issue ")
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.issue)
                    @Html.ValidationMessageFor(model => model.issue)
                </div>
                @*-----------Volume-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.volume, "Volume ")
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.volume)
                    @Html.ValidationMessageFor(model => model.volume)
                </div>
                @*-----------Page-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.page, "Page ")
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.page)
                    @Html.ValidationMessageFor(model => model.page)
                </div>
                @*-----------Reference ID-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.referenceID, "Location ")
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.referenceID, new { size = 38 })
                    @Html.ValidationMessageFor(model => model.referenceID)
                </div>
                @*-----------Keywords-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.keyword, "Keywords")
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.keyword, new { size = 78 })
                    @Html.ValidationMessageFor(model => model.keyword)
                </div>
                @*-----------Description-----------*@
                <div class="editor-label">
                    @Html.LabelFor(model => model.description, "Abstract ")
                </div>
                <div class="editor-field">
                    @Html.TextAreaFor(model => model.description, new { cols = "49", rows = "5" })
                    @Html.ValidationMessageFor(model => model.description)
                </div>
            </fieldset>
            <p>
                <input type="submit" value="Save" style="float: right; padding: 3px 8px;" />
            </p>
    
        }
    </div>
</div>
<div class="grid_3">
    <div class="box">
        <h2>
            Bookmarks</h2>
        @*@{Html.RenderAction("ProgressTracker", "Profile");}*@
    </div>
</div>
@Html.Partial("_Footer")
@helper Script(string scriptName)
    {
    <script src="@Url.Content("~/Scripts/" + scriptName)" type="text/javascript"></script>
}
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
       if ($('#journal').length) {
            AutoCompleteJournal();
        }
        if ($('#publisher').length) {
            AutoCompletePublisher();
        }
        if ($('#conference').length) {
            AutoCompleteConference();
        }
        if ($('#university').length) {
            AutoCompleteUniversity();
        }
    });

        function AutoCompleteJournal() 
        {
            $("#journal").autocomplete({source: function (request, response) {$.ajax({
            url: "/PublicationModel/findJournalNames", type: "POST", dataType: "json",
            data: { searchText: request.term, maxResults: 5 },
            success: function (data) {
            response($.map(data, function (item) {
            return { label: item.Name, value: item.Name, id: item.JournalID }
                }))
                }
                })
                },
            });
        }


            function AutoCompletePublisher() 
        {
            $("#publisher").autocomplete({source: function (request, response) {$.ajax({
            url: "/PublicationModel/findPublisherNames", type: "POST", dataType: "json",
            data: { searchText: request.term, maxResults: 5 },
            success: function (data) {
            response($.map(data, function (item) {
            return { label: item.Name, value: item.Name, id: item.PublisherID }
                }))
                }
                })
                },
            });
        }

            function AutoCompleteConference() 
        {
            $("#conference").autocomplete({source: function (request, response) {$.ajax({
            url: "/PublicationModel/findConferenceNames", type: "POST", dataType: "json",
            data: { searchText: request.term, maxResults: 5 },
            success: function (data) {
            response($.map(data, function (item) {
            return { label: item.Name, value: item.Name, id: item.ConferenceID }
                }))
                }
                })
                },
            });
        }

        function AutoCompleteUniversity() 
        {
            $("#university").autocomplete({source: function (request, response) {$.ajax({
            url: "/PublicationModel/findUniversityNames", type: "POST", dataType: "json",
            data: { searchText: request.term, maxResults: 5 },
            success: function (data) {
            response($.map(data, function (item) {
            return { label: item.Name, value: item.Name, id: item.UniversityID }
                }))
                }
                })
                },
            });
        }

</script>
